package com.wuyou.sso.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * Mybatis Plus配置
 *
 * @author lishangbu
 * @date 2019/10/11
 */
@Configuration
//@ConditionalOnBean(DataSource.class)
//@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@MapperScan("com.wuyou.**.mapper")
public class MybatisPlusConfiguration {

//    @Autowired
//    private DatabaseProperties databaseProperties;
//
//    /**
//     * mybatis plus 拦截器配置
//     */
//    @Bean
//    @ConditionalOnMissingBean(MybatisPlusInterceptor.class)
//    public MybatisPlusInterceptor mybatisPlusInterceptor() {
//        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
//        if (databaseProperties.getMultiTenantType().eq(MultiTenantType.SCHEMA)) {
//            // SCHEMA 动态表名插件
//            SchemaInterceptor schemaInterceptor = new SchemaInterceptor(databaseProperties.getTenantDatabasePrefix());
//            mybatisPlusInterceptor.addInnerInterceptor(schemaInterceptor);
//        }
//        // 添加分页支持
//        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
//        return mybatisPlusInterceptor;
//    }

    /**
     * 拓展方法
     *
     * @return
     */
//    @Bean
//    public ExpandSqlInjector expandSqlInjector() {
//        return new ExpandSqlInjector();
//    }

}
